package com.aipartner.mapper;

import com.aipartner.entity.CreditsConsumptionConfig;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 积分消耗配置 Mapper 接口
 *
 * @author AI Partner
 * @since 2025-09-18
 */
@Mapper
public interface CreditsConsumptionConfigMapper extends BaseMapper<CreditsConsumptionConfig> {

    /**
     * 获取所有启用的消耗配置
     */
    @Select("SELECT * FROM credits_consumption_config WHERE is_active = true ORDER BY id ASC")
    List<CreditsConsumptionConfig> selectActiveConfigs();

    /**
     * 根据服务类型获取积分消耗
     */
    @Select("SELECT credits_cost FROM credits_consumption_config WHERE service_type = #{serviceType} AND is_active = true")
    Long selectCreditsCostByServiceType(@Param("serviceType") String serviceType);
}
